local quanmianfazhan = fk.CreateSkill {
  name = "lingling__quanmianfazhan",
}

Fk:loadTranslationTable {
  ["lingling__quanmianfazhan"] = "全面发展",
  [":lingling__quanmianfazhan"] = "摸牌阶段，你可以改为随机获得每种类型的牌各一张，然后若你手牌有四种花色，你摸一张牌。",
  ["#lingling__quanmianfazhan-invoke"] = "全面发展：是否将摸牌阶段改为随机获得手牌中每种类型的牌各一张？",
}

quanmianfazhan:addEffect(fk.EventPhaseStart, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(quanmianfazhan.name) and player.phase == Player.Draw and
        not data.phase_end
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {
      prompt = "#lingling__quanmianfazhan-invoke",
      skill_name = quanmianfazhan.name,
    })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player.dead then return end
    data.phase_end = true
    local get = {}
    for _, t in ipairs({ "basic", "trick", "equip" }) do
      local cards = room:getCardsFromPileByRule(".|.|.|.|.|" .. t, 1, "allPiles")
      if cards then
        table.insert(get, cards[1])
      end
    end
    if #get > 0 then
      room:obtainCard(player, get, false, fk.ReasonJustMove, player, self.name)
    end
    if player.dead then return end
    local suits = {}
    for _, id in ipairs(player:getCardIds("h")) do
      table.insertIfNeed(suits, Fk:getCardById(id).suit)
    end
    if #suits == 4 then
      player:drawCards(1, quanmianfazhan.name)
    end
  end,
})

return quanmianfazhan
